package com.wen.tian.controller;

import com.wen.tian.bean.Result;
import com.wen.tian.bean.ResultUtil;
import com.wen.tian.pojo.SysUser;
import org.apache.shiro.SecurityUtils;

/**
 * @author tww
 * ClassName: BaseController.java、
 * createTime: 2021年01月02日 16:58:15
 **/
public class BaseController {
    /**
     * 获取当前登录用户
     *
     * @return SysUsers
     */
    protected SysUser getSysUser() {
        return (SysUser) SecurityUtils.getSubject().getPrincipal();
    }

    /**
     * 返回成功
     */
    protected Result success(Integer code, String msg) {
        return ResultUtil.success(code, msg);
    }

    /**
     * 返回成功
     */
    protected Result success(Integer code, String msg, Object data) {
        return ResultUtil.success(code, msg, data);
    }

    /**
     * 返回失败消息
     */
    protected Result error(Integer code, String message) {
        return ResultUtil.error(code, message);
    }
}
